﻿//////////////////////////////////////////////////////////////
// <auto-generated>This code was generated by LLBLGen Pro 5.9.</auto-generated>
//////////////////////////////////////////////////////////////
// Code is generated on: 
// Code is generated using templates: SD.TemplateBindings.SharedTemplates
// Templates vendor: Solutions Design.
//////////////////////////////////////////////////////////////
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using LLBLGenPro.OrmCookbook.HelperClasses;
using LLBLGenPro.OrmCookbook.FactoryClasses;
using LLBLGenPro.OrmCookbook.RelationClasses;

using SD.LLBLGen.Pro.ORMSupportClasses;

namespace LLBLGenPro.OrmCookbook.EntityClasses
{
	// __LLBLGENPRO_USER_CODE_REGION_START AdditionalNamespaces
	// __LLBLGENPRO_USER_CODE_REGION_END
	/// <summary>Entity class which represents the entity 'Employee'.<br/><br/></summary>
	[Serializable]
	public partial class EmployeeEntity : CommonEntityBase, Recipes.IEmployeeComplex, Recipes.IEmployeeSimple
		// __LLBLGENPRO_USER_CODE_REGION_START AdditionalInterfaces
		// __LLBLGENPRO_USER_CODE_REGION_END	
	{
		private EntityCollection<DepartmentEntity> _createdDepartments;
		private EntityCollection<DepartmentEntity> _modifiedDepartments;
		private EntityCollection<DivisionEntity> _divisionsCreatedByEmployee;
		private EntityCollection<DivisionEntity> _divisionsModifiedByEmployee;
		private EmployeeClassificationEntity _employeeClassification;

		// __LLBLGENPRO_USER_CODE_REGION_START PrivateMembers
		// __LLBLGENPRO_USER_CODE_REGION_END
		private static EmployeeEntityStaticMetaData _staticMetaData = new EmployeeEntityStaticMetaData();
		private static EmployeeRelations _relationsFactory = new EmployeeRelations();

		/// <summary>All names of fields mapped onto a relation. Usable for in-memory filtering</summary>
		public static partial class MemberNames
		{
			/// <summary>Member name EmployeeClassification</summary>
			public static readonly string EmployeeClassification = "EmployeeClassification";
			/// <summary>Member name CreatedDepartments</summary>
			public static readonly string CreatedDepartments = "CreatedDepartments";
			/// <summary>Member name ModifiedDepartments</summary>
			public static readonly string ModifiedDepartments = "ModifiedDepartments";
			/// <summary>Member name DivisionsCreatedByEmployee</summary>
			public static readonly string DivisionsCreatedByEmployee = "DivisionsCreatedByEmployee";
			/// <summary>Member name DivisionsModifiedByEmployee</summary>
			public static readonly string DivisionsModifiedByEmployee = "DivisionsModifiedByEmployee";
		}

		/// <summary>Static meta-data storage for navigator related information</summary>
		protected class EmployeeEntityStaticMetaData : EntityStaticMetaDataBase
		{
			public EmployeeEntityStaticMetaData()
			{
				SetEntityCoreInfo("EmployeeEntity", InheritanceHierarchyType.None, false, (int)LLBLGenPro.OrmCookbook.EntityType.EmployeeEntity, typeof(EmployeeEntity), typeof(EmployeeEntityFactory), false);
				AddNavigatorMetaData<EmployeeEntity, EntityCollection<DepartmentEntity>>("CreatedDepartments", a => a._createdDepartments, (a, b) => a._createdDepartments = b, a => a.CreatedDepartments, () => new EmployeeRelations().DepartmentEntityUsingCreatedByEmployeeKey, typeof(DepartmentEntity), (int)LLBLGenPro.OrmCookbook.EntityType.DepartmentEntity);
				AddNavigatorMetaData<EmployeeEntity, EntityCollection<DepartmentEntity>>("ModifiedDepartments", a => a._modifiedDepartments, (a, b) => a._modifiedDepartments = b, a => a.ModifiedDepartments, () => new EmployeeRelations().DepartmentEntityUsingModifiedByEmployeeKey, typeof(DepartmentEntity), (int)LLBLGenPro.OrmCookbook.EntityType.DepartmentEntity);
				AddNavigatorMetaData<EmployeeEntity, EntityCollection<DivisionEntity>>("DivisionsCreatedByEmployee", a => a._divisionsCreatedByEmployee, (a, b) => a._divisionsCreatedByEmployee = b, a => a.DivisionsCreatedByEmployee, () => new EmployeeRelations().DivisionEntityUsingCreatedByEmployeeKey, typeof(DivisionEntity), (int)LLBLGenPro.OrmCookbook.EntityType.DivisionEntity);
				AddNavigatorMetaData<EmployeeEntity, EntityCollection<DivisionEntity>>("DivisionsModifiedByEmployee", a => a._divisionsModifiedByEmployee, (a, b) => a._divisionsModifiedByEmployee = b, a => a.DivisionsModifiedByEmployee, () => new EmployeeRelations().DivisionEntityUsingModifiedByEmployeeKey, typeof(DivisionEntity), (int)LLBLGenPro.OrmCookbook.EntityType.DivisionEntity);
				AddNavigatorMetaData<EmployeeEntity, EmployeeClassificationEntity>("EmployeeClassification", "Employees", (a, b) => a._employeeClassification = b, a => a._employeeClassification, (a, b) => a.EmployeeClassification = b, LLBLGenPro.OrmCookbook.RelationClasses.StaticEmployeeRelations.EmployeeClassificationEntityUsingEmployeeClassificationKeyStatic, ()=>new EmployeeRelations().EmployeeClassificationEntityUsingEmployeeClassificationKey, null, new int[] { (int)EmployeeFieldIndex.EmployeeClassificationKey }, null, true, (int)LLBLGenPro.OrmCookbook.EntityType.EmployeeClassificationEntity);
			}
		}

		/// <summary>Static ctor</summary>
		static EmployeeEntity()
		{
		}

		/// <summary> CTor</summary>
		public EmployeeEntity()
		{
			InitClassEmpty(null, null);
		}

		/// <summary> CTor</summary>
		/// <param name="fields">Fields object to set as the fields for this entity.</param>
		public EmployeeEntity(IEntityFields2 fields)
		{
			InitClassEmpty(null, fields);
		}

		/// <summary> CTor</summary>
		/// <param name="validator">The custom validator object for this EmployeeEntity</param>
		public EmployeeEntity(IValidator validator)
		{
			InitClassEmpty(validator, null);
		}

		/// <summary> CTor</summary>
		/// <param name="employeeKey">PK value for Employee which data should be fetched into this Employee object</param>
		public EmployeeEntity(System.Int32 employeeKey) : this(employeeKey, null)
		{
		}

		/// <summary> CTor</summary>
		/// <param name="employeeKey">PK value for Employee which data should be fetched into this Employee object</param>
		/// <param name="validator">The custom validator object for this EmployeeEntity</param>
		public EmployeeEntity(System.Int32 employeeKey, IValidator validator)
		{
			InitClassEmpty(validator, null);
			this.EmployeeKey = employeeKey;
		}

		/// <summary>Private CTor for deserialization</summary>
		/// <param name="info"></param>
		/// <param name="context"></param>
		protected EmployeeEntity(SerializationInfo info, StreamingContext context) : base(info, context)
		{
			// __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
			// __LLBLGENPRO_USER_CODE_REGION_END
		}

		/// <summary>Creates a new IRelationPredicateBucket object which contains the predicate expression and relation collection to fetch the related entities of type 'Department' to this entity.</summary>
		/// <returns></returns>
		public virtual IRelationPredicateBucket GetRelationInfoCreatedDepartments() { return CreateRelationInfoForNavigator("CreatedDepartments"); }

		/// <summary>Creates a new IRelationPredicateBucket object which contains the predicate expression and relation collection to fetch the related entities of type 'Department' to this entity.</summary>
		/// <returns></returns>
		public virtual IRelationPredicateBucket GetRelationInfoModifiedDepartments() { return CreateRelationInfoForNavigator("ModifiedDepartments"); }

		/// <summary>Creates a new IRelationPredicateBucket object which contains the predicate expression and relation collection to fetch the related entities of type 'Division' to this entity.</summary>
		/// <returns></returns>
		public virtual IRelationPredicateBucket GetRelationInfoDivisionsCreatedByEmployee() { return CreateRelationInfoForNavigator("DivisionsCreatedByEmployee"); }

		/// <summary>Creates a new IRelationPredicateBucket object which contains the predicate expression and relation collection to fetch the related entities of type 'Division' to this entity.</summary>
		/// <returns></returns>
		public virtual IRelationPredicateBucket GetRelationInfoDivisionsModifiedByEmployee() { return CreateRelationInfoForNavigator("DivisionsModifiedByEmployee"); }

		/// <summary>Creates a new IRelationPredicateBucket object which contains the predicate expression and relation collection to fetch the related entity of type 'EmployeeClassification' to this entity.</summary>
		/// <returns></returns>
		public virtual IRelationPredicateBucket GetRelationInfoEmployeeClassification() { return CreateRelationInfoForNavigator("EmployeeClassification"); }
		
		/// <inheritdoc/>
		protected override EntityStaticMetaDataBase GetEntityStaticMetaData() {	return _staticMetaData; }

		/// <summary>Initializes the class members</summary>
		private void InitClassMembers()
		{
			PerformDependencyInjection();
			// __LLBLGENPRO_USER_CODE_REGION_START InitClassMembers
			// __LLBLGENPRO_USER_CODE_REGION_END
			OnInitClassMembersComplete();
		}

		/// <summary>Initializes the class with empty data, as if it is a new Entity.</summary>
		/// <param name="validator">The validator object for this EmployeeEntity</param>
		/// <param name="fields">Fields of this entity</param>
		private void InitClassEmpty(IValidator validator, IEntityFields2 fields)
		{
			OnInitializing();
			this.Fields = fields ?? CreateFields();
			this.Validator = validator;
			InitClassMembers();
			// __LLBLGENPRO_USER_CODE_REGION_START InitClassEmpty
			// __LLBLGENPRO_USER_CODE_REGION_END

			OnInitialized();
		}

		/// <summary>The relations object holding all relations of this entity with other entity classes.</summary>
		public static EmployeeRelations Relations { get { return _relationsFactory; } }

		/// <summary>Creates a new PrefetchPathElement2 object which contains all the information to prefetch the related entities of type 'Department' for this entity.</summary>
		/// <returns>Ready to use IPrefetchPathElement2 implementation.</returns>
		public static IPrefetchPathElement2 PrefetchPathCreatedDepartments { get { return _staticMetaData.GetPrefetchPathElement("CreatedDepartments", CommonEntityBase.CreateEntityCollection<DepartmentEntity>()); } }

		/// <summary>Creates a new PrefetchPathElement2 object which contains all the information to prefetch the related entities of type 'Department' for this entity.</summary>
		/// <returns>Ready to use IPrefetchPathElement2 implementation.</returns>
		public static IPrefetchPathElement2 PrefetchPathModifiedDepartments { get { return _staticMetaData.GetPrefetchPathElement("ModifiedDepartments", CommonEntityBase.CreateEntityCollection<DepartmentEntity>()); } }

		/// <summary>Creates a new PrefetchPathElement2 object which contains all the information to prefetch the related entities of type 'Division' for this entity.</summary>
		/// <returns>Ready to use IPrefetchPathElement2 implementation.</returns>
		public static IPrefetchPathElement2 PrefetchPathDivisionsCreatedByEmployee { get { return _staticMetaData.GetPrefetchPathElement("DivisionsCreatedByEmployee", CommonEntityBase.CreateEntityCollection<DivisionEntity>()); } }

		/// <summary>Creates a new PrefetchPathElement2 object which contains all the information to prefetch the related entities of type 'Division' for this entity.</summary>
		/// <returns>Ready to use IPrefetchPathElement2 implementation.</returns>
		public static IPrefetchPathElement2 PrefetchPathDivisionsModifiedByEmployee { get { return _staticMetaData.GetPrefetchPathElement("DivisionsModifiedByEmployee", CommonEntityBase.CreateEntityCollection<DivisionEntity>()); } }

		/// <summary>Creates a new PrefetchPathElement2 object which contains all the information to prefetch the related entities of type 'EmployeeClassification' for this entity.</summary>
		/// <returns>Ready to use IPrefetchPathElement2 implementation.</returns>
		public static IPrefetchPathElement2 PrefetchPathEmployeeClassification { get { return _staticMetaData.GetPrefetchPathElement("EmployeeClassification", CommonEntityBase.CreateEntityCollection<EmployeeClassificationEntity>()); } }

		/// <summary>The CellPhone property of the Entity Employee<br/><br/></summary>
		/// <remarks>Mapped on  table field: "Employee"."CellPhone".<br/>Table field type characteristics (type, precision, scale, length): VarChar, 0, 0, 15.<br/>Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.String CellPhone
		{
			get { return (System.String)GetValue((int)EmployeeFieldIndex.CellPhone, true); }
			set	{ SetValue((int)EmployeeFieldIndex.CellPhone, value); }
		}

		/// <summary>The EmployeeClassificationKey property of the Entity Employee<br/><br/></summary>
		/// <remarks>Mapped on  table field: "Employee"."EmployeeClassificationKey".<br/>Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0.<br/>Table field behavior characteristics (is nullable, is PK, is identity): false, false, false</remarks>
		public virtual System.Int32 EmployeeClassificationKey
		{
			get { return (System.Int32)GetValue((int)EmployeeFieldIndex.EmployeeClassificationKey, true); }
			set	{ SetValue((int)EmployeeFieldIndex.EmployeeClassificationKey, value); }
		}

		/// <summary>The EmployeeKey property of the Entity Employee<br/><br/></summary>
		/// <remarks>Mapped on  table field: "Employee"."EmployeeKey".<br/>Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0.<br/>Table field behavior characteristics (is nullable, is PK, is identity): false, true, true</remarks>
		public virtual System.Int32 EmployeeKey
		{
			get { return (System.Int32)GetValue((int)EmployeeFieldIndex.EmployeeKey, true); }
			set { SetValue((int)EmployeeFieldIndex.EmployeeKey, value); }		}

		/// <summary>The FirstName property of the Entity Employee<br/><br/></summary>
		/// <remarks>Mapped on  table field: "Employee"."FirstName".<br/>Table field type characteristics (type, precision, scale, length): NVarChar, 0, 0, 50.<br/>Table field behavior characteristics (is nullable, is PK, is identity): false, false, false</remarks>
		public virtual System.String FirstName
		{
			get { return (System.String)GetValue((int)EmployeeFieldIndex.FirstName, true); }
			set	{ SetValue((int)EmployeeFieldIndex.FirstName, value); }
		}

		/// <summary>The LastName property of the Entity Employee<br/><br/></summary>
		/// <remarks>Mapped on  table field: "Employee"."LastName".<br/>Table field type characteristics (type, precision, scale, length): NVarChar, 0, 0, 50.<br/>Table field behavior characteristics (is nullable, is PK, is identity): false, false, false</remarks>
		public virtual System.String LastName
		{
			get { return (System.String)GetValue((int)EmployeeFieldIndex.LastName, true); }
			set	{ SetValue((int)EmployeeFieldIndex.LastName, value); }
		}

		/// <summary>The MiddleName property of the Entity Employee<br/><br/></summary>
		/// <remarks>Mapped on  table field: "Employee"."MiddleName".<br/>Table field type characteristics (type, precision, scale, length): NVarChar, 0, 0, 50.<br/>Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.String MiddleName
		{
			get { return (System.String)GetValue((int)EmployeeFieldIndex.MiddleName, true); }
			set	{ SetValue((int)EmployeeFieldIndex.MiddleName, value); }
		}

		/// <summary>The OfficePhone property of the Entity Employee<br/><br/></summary>
		/// <remarks>Mapped on  table field: "Employee"."OfficePhone".<br/>Table field type characteristics (type, precision, scale, length): VarChar, 0, 0, 15.<br/>Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.String OfficePhone
		{
			get { return (System.String)GetValue((int)EmployeeFieldIndex.OfficePhone, true); }
			set	{ SetValue((int)EmployeeFieldIndex.OfficePhone, value); }
		}

		/// <summary>The Title property of the Entity Employee<br/><br/></summary>
		/// <remarks>Mapped on  table field: "Employee"."Title".<br/>Table field type characteristics (type, precision, scale, length): NVarChar, 0, 0, 100.<br/>Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.String Title
		{
			get { return (System.String)GetValue((int)EmployeeFieldIndex.Title, true); }
			set	{ SetValue((int)EmployeeFieldIndex.Title, value); }
		}

		/// <summary>Gets the EntityCollection with the related entities of type 'DepartmentEntity' which are related to this entity via a relation of type '1:n'. If the EntityCollection hasn't been fetched yet, the collection returned will be empty.<br/><br/></summary>
		[TypeContainedAttribute(typeof(DepartmentEntity))]
		public virtual EntityCollection<DepartmentEntity> CreatedDepartments { get { return GetOrCreateEntityCollection<DepartmentEntity, DepartmentEntityFactory>("CreatedByEmployee", true, false, ref _createdDepartments); } }

		/// <summary>Gets the EntityCollection with the related entities of type 'DepartmentEntity' which are related to this entity via a relation of type '1:n'. If the EntityCollection hasn't been fetched yet, the collection returned will be empty.<br/><br/></summary>
		[TypeContainedAttribute(typeof(DepartmentEntity))]
		public virtual EntityCollection<DepartmentEntity> ModifiedDepartments { get { return GetOrCreateEntityCollection<DepartmentEntity, DepartmentEntityFactory>("ModifiedByEmployee", true, false, ref _modifiedDepartments); } }

		/// <summary>Gets the EntityCollection with the related entities of type 'DivisionEntity' which are related to this entity via a relation of type '1:n'. If the EntityCollection hasn't been fetched yet, the collection returned will be empty.<br/><br/></summary>
		[TypeContainedAttribute(typeof(DivisionEntity))]
		public virtual EntityCollection<DivisionEntity> DivisionsCreatedByEmployee { get { return GetOrCreateEntityCollection<DivisionEntity, DivisionEntityFactory>("CreatedByEmployee", true, false, ref _divisionsCreatedByEmployee); } }

		/// <summary>Gets the EntityCollection with the related entities of type 'DivisionEntity' which are related to this entity via a relation of type '1:n'. If the EntityCollection hasn't been fetched yet, the collection returned will be empty.<br/><br/></summary>
		[TypeContainedAttribute(typeof(DivisionEntity))]
		public virtual EntityCollection<DivisionEntity> DivisionsModifiedByEmployee { get { return GetOrCreateEntityCollection<DivisionEntity, DivisionEntityFactory>("ModifiedByEmployee", true, false, ref _divisionsModifiedByEmployee); } }

		/// <summary>Gets / sets related entity of type 'EmployeeClassificationEntity' which has to be set using a fetch action earlier. If no related entity is set for this property, null is returned..<br/><br/></summary>
		[Browsable(false)]
		public virtual EmployeeClassificationEntity EmployeeClassification
		{
			get { return _employeeClassification; }
			set { SetSingleRelatedEntityNavigator(value, "EmployeeClassification"); }
		}

		// __LLBLGENPRO_USER_CODE_REGION_START CustomEntityCode
		// __LLBLGENPRO_USER_CODE_REGION_END

	}
}

namespace LLBLGenPro.OrmCookbook
{
	public enum EmployeeFieldIndex
	{
		///<summary>CellPhone. </summary>
		CellPhone,
		///<summary>EmployeeClassificationKey. </summary>
		EmployeeClassificationKey,
		///<summary>EmployeeKey. </summary>
		EmployeeKey,
		///<summary>FirstName. </summary>
		FirstName,
		///<summary>LastName. </summary>
		LastName,
		///<summary>MiddleName. </summary>
		MiddleName,
		///<summary>OfficePhone. </summary>
		OfficePhone,
		///<summary>Title. </summary>
		Title,
		/// <summary></summary>
		AmountOfFields
	}
}

namespace LLBLGenPro.OrmCookbook.RelationClasses
{
	/// <summary>Implements the relations factory for the entity: Employee. </summary>
	public partial class EmployeeRelations: RelationFactory
	{
		/// <summary>Returns a new IEntityRelation object, between EmployeeEntity and DepartmentEntity over the 1:n relation they have, using the relation between the fields: Employee.EmployeeKey - Department.CreatedByEmployeeKey</summary>
		public virtual IEntityRelation DepartmentEntityUsingCreatedByEmployeeKey
		{
			get { return ModelInfoProviderSingleton.GetInstance().CreateRelation(RelationType.OneToMany, "CreatedDepartments", true, new[] { EmployeeFields.EmployeeKey, DepartmentFields.CreatedByEmployeeKey }); }
		}

		/// <summary>Returns a new IEntityRelation object, between EmployeeEntity and DepartmentEntity over the 1:n relation they have, using the relation between the fields: Employee.EmployeeKey - Department.ModifiedByEmployeeKey</summary>
		public virtual IEntityRelation DepartmentEntityUsingModifiedByEmployeeKey
		{
			get { return ModelInfoProviderSingleton.GetInstance().CreateRelation(RelationType.OneToMany, "ModifiedDepartments", true, new[] { EmployeeFields.EmployeeKey, DepartmentFields.ModifiedByEmployeeKey }); }
		}

		/// <summary>Returns a new IEntityRelation object, between EmployeeEntity and DivisionEntity over the 1:n relation they have, using the relation between the fields: Employee.EmployeeKey - Division.CreatedByEmployeeKey</summary>
		public virtual IEntityRelation DivisionEntityUsingCreatedByEmployeeKey
		{
			get { return ModelInfoProviderSingleton.GetInstance().CreateRelation(RelationType.OneToMany, "DivisionsCreatedByEmployee", true, new[] { EmployeeFields.EmployeeKey, DivisionFields.CreatedByEmployeeKey }); }
		}

		/// <summary>Returns a new IEntityRelation object, between EmployeeEntity and DivisionEntity over the 1:n relation they have, using the relation between the fields: Employee.EmployeeKey - Division.ModifiedByEmployeeKey</summary>
		public virtual IEntityRelation DivisionEntityUsingModifiedByEmployeeKey
		{
			get { return ModelInfoProviderSingleton.GetInstance().CreateRelation(RelationType.OneToMany, "DivisionsModifiedByEmployee", true, new[] { EmployeeFields.EmployeeKey, DivisionFields.ModifiedByEmployeeKey }); }
		}

		/// <summary>Returns a new IEntityRelation object, between EmployeeEntity and EmployeeClassificationEntity over the m:1 relation they have, using the relation between the fields: Employee.EmployeeClassificationKey - EmployeeClassification.EmployeeClassificationKey</summary>
		public virtual IEntityRelation EmployeeClassificationEntityUsingEmployeeClassificationKey
		{
			get	{ return ModelInfoProviderSingleton.GetInstance().CreateRelation(RelationType.ManyToOne, "EmployeeClassification", false, new[] { EmployeeClassificationFields.EmployeeClassificationKey, EmployeeFields.EmployeeClassificationKey }); }
		}

	}
	
	/// <summary>Static class which is used for providing relationship instances which are re-used internally for syncing</summary>
	internal static class StaticEmployeeRelations
	{
		internal static readonly IEntityRelation DepartmentEntityUsingCreatedByEmployeeKeyStatic = new EmployeeRelations().DepartmentEntityUsingCreatedByEmployeeKey;
		internal static readonly IEntityRelation DepartmentEntityUsingModifiedByEmployeeKeyStatic = new EmployeeRelations().DepartmentEntityUsingModifiedByEmployeeKey;
		internal static readonly IEntityRelation DivisionEntityUsingCreatedByEmployeeKeyStatic = new EmployeeRelations().DivisionEntityUsingCreatedByEmployeeKey;
		internal static readonly IEntityRelation DivisionEntityUsingModifiedByEmployeeKeyStatic = new EmployeeRelations().DivisionEntityUsingModifiedByEmployeeKey;
		internal static readonly IEntityRelation EmployeeClassificationEntityUsingEmployeeClassificationKeyStatic = new EmployeeRelations().EmployeeClassificationEntityUsingEmployeeClassificationKey;

		/// <summary>CTor</summary>
		static StaticEmployeeRelations() { }
	}
}
